/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.spring66.tutorial.service.ibatis;

import com.spring66.tutorial.dao.AppUserDao;
import com.spring66.tutorial.model.AppUser;
import com.spring66.tutorial.model.AppUserExpression;
import com.spring66.tutorial.service.AppUserService;
import java.util.Date;
import java.util.List;

/**
 *
 * @author twinp
 */
public class IbatisAppUserService implements AppUserService {
    private AppUserDao appUserDao;
    @Override
    public AppUser createUser(AppUser user) {
        Date currentDate = new Date();
        user.setLogDate(currentDate);
        user.setRegDate(currentDate);
        user.setUsrFirstLogin(currentDate);
        System.out.println("user->"+user.getUsrName());
        appUserDao.insert(user);
        //List<Users> users = appUserDao.selectByExpression(expression);
        return user;
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public AppUser getUser(Integer id) {
        //appUserDao.selectByExpression(new UserExpressio)
        //return appUserDao.selectByExpression(userEx);
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<AppUser> getUsers(AppUserExpression userEx) {
        //appUserDao.selectByExpression(new UserExpressio)
        return appUserDao.selectByExpression(userEx);
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void updateUsers(AppUser user) {
        appUserDao.updateByPrimaryKey(user);
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void deleteUser(String userId) {
        appUserDao.deleteByPrimaryKey(userId);
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * @return the appUserDao
     */
    public AppUserDao getappUserDao() {
        return appUserDao;
    }

    /**
     * @param appUserDao the appUserDao to set
     */
    public void setappUserDao(AppUserDao appUserDao) {
        this.appUserDao = appUserDao;
    }

}
